import request from '@/api/request'
// 封装请求

const token = localStorage.getItem('token') || localStorage.getItem('ordinaryUserToken')

export const medicine = ({ currentPage, pageSize, queryString }) => {
  return request({
    url: `/wMedicine/medicine/${currentPage}/${pageSize}`,
    method: 'GET',
    params: {
      queryString
    },
    headers: {
      accept: 'application/json',
      Authorization: `Bearer ${token}`
    }
  })
}

export const medicineClient = ({ currentPage, pageSize, queryString }) => {
  return request({
    url: `/wMedicine/medicineClient/${currentPage}/${pageSize}`,
    method: 'GET',
    params: {
      queryString
    },
    headers: {
      accept: 'application/json',
      Authorization: `Bearer ${token}`
    }
  })
}

export const TcMedicine = ({ currentPage, pageSize, queryString }) => {
  return request({
    url: `/tcMedicine/tr/${currentPage}/${pageSize}`,
    method: 'GET',
    params: {
      queryString
    },
    headers: {
      accept: 'application/json',
      Authorization: `Bearer ${token}`
    }
  })
}
export const TcMedicineClient = ({ currentPage, pageSize, queryString }) => {
  return request({
    url: `/tcMedicine/trClient/${currentPage}/${pageSize}`,
    method: 'GET',
    params: {
      queryString
    }
    // headers: {
    //   accept: 'application/json',
    //   Authorization: `Bearer ${token}`
    // }
  })
}

export const searchTcMedicineClient = ({ currentPage, pageSize, category }) => {
  return request({
    // url: `/tcMedicine/searchClient/${currentPage}/${pageSize}`,
    url: `/tcMedicine/searchClient/${currentPage}/${pageSize}`,
    method: 'GET',
    params: {
      category
    }
    // headers: {
    //   accept: 'application/json',
    //   Authorization: `Bearer ${token}`
    // }
  })
}
export const TcMedicineList = () => {
  return request({
    url: '/tcMedicine/tr',
    method: 'GET',
    headers: {
      accept: 'application/json',
      Authorization: `Bearer ${token}`
    }
  })
}

export const TcMedicineEdit = (id) => {
  return request({
    url: `/tcMedicine/${id}`,
    method: 'GET',
    headers: {
      accept: 'application/json',
      Authorization: `Bearer ${token}`
    }
  })
}

// 分类
export const TcMedicineCategory = () => {
  return request({
    url: '/category/tcClassify',
    method: 'GET',
    headers: {
      accept: 'application/json',
      Authorization: `Bearer ${token}`
    }
  })
}

export const TcMedicineAdd = (data) => {
  return request({
    url: '/tcMedicine/insertTcMedicine',
    method: 'POST',
    data
  })
}

export const TcMedicineUpdate = (data) => {
  return request({
    url: '/tcMedicine/updateTcMedicine',
    method: 'PUT',
    data
    // headers: {
    //   accept: 'application/json',
    //   Authorization: `Bearer ${token}`
    // }
  })
}

// 当前接口支持批量删除 和 单个删除
export const TcMedicineDelete = (ids) => {
  return request({
    url: `/tcMedicine/deleteTcMedicine/${ids}`,
    method: 'DELETE'
    // headers: {
    //   accept: 'application/json',
    //   Authorization: `Bearer ${token}`
    // }
  })
}
